package com.ssy.lingxi.platform.template.service.controller.web;

import com.ssy.lingxi.common.controller.BaseController;
import com.ssy.lingxi.common.model.vo.PageVO;
import com.ssy.lingxi.common.response.PageData;
import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.platform.template.service.entity.door.MemberLogistics;
import com.ssy.lingxi.platform.template.service.model.dto.common.CollectDTO;
import com.ssy.lingxi.platform.template.service.model.dto.common.IdDTO;
import com.ssy.lingxi.platform.template.service.model.dto.common.IdListDTO;
import com.ssy.lingxi.platform.template.service.model.dto.web.SaveLogisticsDTO;
import com.ssy.lingxi.platform.template.service.model.qo.MemberLogisticsQO;
import com.ssy.lingxi.platform.template.service.model.vo.web.MemberLogisticsListVO;
import com.ssy.lingxi.platform.template.service.model.vo.web.MemberLogisticsMainVO;
import com.ssy.lingxi.platform.template.service.service.web.MemberLogisticsWebService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * @menu web - 会员物流门户
 * @author fhj
 * @version 2.0.0
 * @date 2021/04/14
 */
@Api(tags = "web - 会员物流门户")
@RestController
@RequestMapping("/template/web/memberLogisticsWeb")
public class MemberLogisticsWebController extends BaseController {

    @Resource
    private MemberLogisticsWebService memberLogisticsWebService;

    @ApiOperation(value = "保存当前登录会员的物流门户")
    @PostMapping("/saveCurrMemberLogistics")
    public Wrapper<Void> saveCurrMemberLogistics(@RequestBody @Valid SaveLogisticsDTO dto) {
        return memberLogisticsWebService.saveCurrMemberLogistics(dto, getSysUser());
    }

    @ApiOperation(value = "获取当前登录会员的物流门户")
    @GetMapping("/findCurrMemberLogistics")
    public Wrapper<MemberLogistics> findCurrMemberLogistics() {
        return memberLogisticsWebService.findCurrMemberLogistics(getSysUser());
    }

    @ApiOperation(value = "物流门户列表")
    @GetMapping("/memberLogisticsList")
    public Wrapper<PageData<MemberLogisticsListVO>> memberLogisticsList(@Valid MemberLogisticsQO qo) {
        return memberLogisticsWebService.memberLogisticsList(qo);
    }

    @ApiOperation(value = "物流门户主页")
    @GetMapping("/memberLogisticsMain")
    public Wrapper<MemberLogisticsMainVO> memberLogisticsMain(@Valid IdDTO dto) {
        return memberLogisticsWebService.memberLogisticsMain(dto, isLogin() ? getSysUser() : null);
    }

    @ApiOperation(value = "根据物流门户ID集合获取物流门户")
    @GetMapping("/findByIdIn")
    public Wrapper<List<MemberLogistics>> findByIdIn(@Valid IdListDTO dto) {
        return memberLogisticsWebService.findByIdIn(dto);
    }

    @ApiOperation(value = "收藏/取消收藏")
    @PostMapping(value = "/collect")
    public Wrapper<Void> collect(@RequestBody @Validated CollectDTO dto) {
        return memberLogisticsWebService.collect(dto, getSysUser());
    }

    @ApiOperation(value = "收藏列表")
    @GetMapping(value = "/collectList")
    public Wrapper<PageData<MemberLogistics>> collectList(PageVO dto) {
        return memberLogisticsWebService.collectList(dto, getSysUser());
    }
}
